<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/jifen.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body>
<div id="main">
  <div class="jifen_list" id="jifen_list"> </div>
</div>
</body>
<script>
	zy_init();
	var page=1;
	
	function jump(id){		
		localStorage['jifen_id']=id;
		uexWindow.open('jifen_show','0','jifen_show.html','2','', '',0);
	}
	
	function getmain(t){
		if (t==-1){
			$$('main').className="loading";
		}
		if(t<1){
			page=1;
		}
		var url = app_path+'index.php?m=iappJifen&c=app&a=lists&catid='+catid_cur('jifen')+'&order='+filter_order_pro('jifen')+'&page='+page;
		uexXmlHttpMgr.open(t,'post',url,"8000");
		uexXmlHttpMgr.send(t);
	}
	
	window.uexOnload=function(type){
		if (!type){
			uexWindow.evaluateScript('',0,"$$('content').className='';");
			uexWindow.setBounce("1");
			uexWindow.setBounceParams("0",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"","pullToReloadText":"拖动刷新","releaseToReloadText":"释放刷新","loadingText":"加载中，请稍等"}');
	　　　　	uexWindow.setBounceParams("1",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"","pullToReloadText":"上拉加载更多","releaseToReloadText":"释放加载","loadingText":"加载中，请稍等"}');
            uexWindow.showBounceView("0","#f3f3f3","1");
            uexWindow.notifyBounceEvent("0","1");
			uexWindow.showBounceView("1","#f3f3f3","1");
　　　　		uexWindow.notifyBounceEvent("1","1");
			uexWindow.onBounceStateChange=function(t,s){
　　　　　　		if(t=="0"||t=="1"){
　　　　　　　　		if(s=="2"){
						getmain(t);
					}
				}
			}
			
			uexXmlHttpMgr.onData = function(opId, status, data){
				if(status==1){
					if(opId<1){					
						$$('jifen_list').innerHTML='';
						uexWindow.setBounceParams("0",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"上次更新：'+Now()+'","pullToReloadText":"拖动刷新","releaseToReloadText":"释放刷新","loadingText":"加载中，请稍等"}');
					}
					uexXmlHttpMgr.close(opId);
					uexWindow.resetBounceView(opId);
					data = JSON.parse(data);	
					var List=data['data'];
					if(List.length>0){
						page++;
						$$("main").className = '';
						for (k in List) {
							var div = document.createElement("div");
							div.className = 'item';
							div.setAttribute("onclick", "javascript:jump(" + List[k]['id'] + "," + List[k]['catid'] + ",\'" + List[k]['title'] + "\');");
							div.setAttribute("ontouchstart", "javascript:zy_touch('down');");
							var html = ''
							html += '<div class="logo"><div class="loadimg"><img src="' + List[k]['image'] + '" class="hide" onload="this.className=\'\'" /></div></div>';
							html += '<div class="txt">';
							html += '<strong>' + List[k]['title'] + '</strong>';
							html += '<span>分类：' + List[k]['catname'] + ' 库存：'+ List[k]['stock'] +'</span>';
							html += '<span class="tel">兑换价格：' + List[k]['price'] + l_common['head_txt_integral']+'</span>';
							html += '<em>兑换</em>';
							html += '</div>';
							div.innerHTML = html;
							$$('jifen_list').appendChild(div);
						}			
					}else{
						if(opId==-1||opId==0){
							$$("main").className = 'notdata';
						}
					}
				}else if(status ==-1) {//加载失败
					uexXmlHttpMgr.close(opId);
					if(opId==-1){
						$$("main").className='errer';
					}else{
						uexWindow.resetBounceView(opId);
						uexWindow.toast("0","5",'加载失败',1000);
					}
				}
			}
			getmain(-1);
		}
	}
	
	
	
	/*
	
			uexXmlHttpMgr.onData = function(opId, status, data){
				uexXmlHttpMgr.close(opId);
				uexWindow.resetBounceView(opId);
				if(status==1){
					if(opId==0){					
						$$('business_list').innerHTML='';
						uexWindow.setBounceParams("0",'{"textColor":"#666","levelText":"上次更新：'+Now()+'","pullToReloadText":"拖动刷新","releaseToReloadText":"释放刷新","loadingText":"加载中，请稍等"}');
					}
					data = JSON.parse(data);		
					var List = data['list'];
					if (List.length > 0) {
						for (i = 0; i < List.length; i++) {
							var div=document.createElement("div");
							div.className='item';
							div.setAttribute("onclick", "javascript:jump("+List[i]['id']+","+List[i]['catid']+",\'" + List[i]['name'] + "\');");
							div.setAttribute("ontouchstart", "javascript:zy_touch('down');");
							var html = ''
							html += '<div class="logo"><div class="loadimg"><img src="'+List[i]['thumb']+'" class="hide" onload="this.className=\'\'" /></div></div>';
							html += '<div class="txt">';
							html += '<strong>' + List[i]['name'] + '</strong>';
							html += '<span class="tel">电话：'+List[i]['tel']+'</span>';
							html += '<span>' + List[i]['area_cn'] + ' ' + List[i]['xid_cn'] + '</span>';
							if (List[i]['distance']) {
								html += '<em>' + List[i]['distance'] + '</em>';
							}
							html += '</div>';
							
							div.innerHTML = html;
							$$('business_list').appendChild(div);
						}
						page++;
						$$("main").className = '';
					}else{
						uexWindow.toast("0","5",'没有更多数据~',2000);
					}
				}else if(status ==-1) {
					if (opId == 0) {
						$$("business_list").innerHTML = '';
						$$("main").className = 'errer';
						uexWindow.toast("0","5",'加载失败~',2000);
					}else{
						uexWindow.toast("0","5",'更多加载失败~',2000);
					}
				}
			}
			*/





	</script>
</html>